package com.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.dto.ClueGainDto;
import com.crm.entity.Clue;
import com.crm.result.CluePage;
import com.crm.vo.SysDept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface CluesMapper extends BaseMapper<Clue> {
    /**
     * 查询最大的id
     */
    @Select("select max(id) from clue")
    Long selectMaxId();
    /**
     * 新建线索
     */
    void insertClue(Clue clue);

    /**
     * 分页查询
     */
//    List<Clue> selectCluesByCondition(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);
    List<Clue> selectByConditions(CluePage cluePage);

    /**
     * id回显查询
     */
    @Select("select * from clue where id = #{clueid}")
    Clue getClueId(Long clueid);

    /**
     * 补充剩余信息
     */
    void updateClue(Clue clue);

    /**
     * 转为商机
     */
    @Update("update clue set transfer = 1 where id = #{id}")
    void updateTransfer(Long id);

    /**
     * 修改为伪线索
     */
    @Update("update clue set faketype = 1 where id = #{id}")
    void updateFake(Long id);

    /**
     * 删除线索不放入线索池
     */
    @Delete("delete from clue where id = #{id}")
    void deleteClue(Long id);



    //线索数
    @Select("select count(*) from clue where userid = #{userId} and transfer = '0' ")
    Integer getClueCount(Long userId);

    //商机数
    @Select("select count(*) from clue where userid = #{userId} and transfer = '1' ")
    Integer getBusinessCount(Long userId);
    /**
     * 根据部门查询员工
     */
    @Select("select * from dept where dept_id = #{id}")
    List<SysDept> selectAllDepts(Integer id);

    /**
     * 分配功能
     */
    void putAssignment(ClueGainDto clueGainDto);




}
